import {addCounter, addToCar, a} from './mutations-type'

export default {
    [a](content, payload) {
        return new Promise((resolve, reject) => {
            let oldGoods = content.state.carList.find(item => payload.iid === item.iid)

            if (oldGoods) {
                // oldGoods.count += 1
                content.commit(addCounter, oldGoods)
                resolve('商品添加加一')
            }else {
                payload.count = 1
                // state.carList.push(payload)
                content.commit(addToCar, payload)
                resolve('添加新的商品')
            }
        })
        
        }
}